﻿using System;
using Microsoft.Practices.Unity;

using SharedGenomics.Annotations;

namespace SharedGenomics.Workbench.Annotations.Requests
{
    public class AnnotationRequestBuilderFactory : IAnnotationRequestBuilderFactory
    {
        private readonly IUnityContainer _container;

        public AnnotationRequestBuilderFactory(IUnityContainer container)
        {
            this._container = container;
        }

        public IAnnotationRequestStage GetRequestStageFor(AnnotationKey key)
        {
            if (key == AnnotationKey.GoogleSearch)
            {
                return new GoogleSearchAnnotationRequestStage();
            }
            else if (key == AnnotationKey.NcbiSummary)
            {
                return this._container.Resolve<NcbiAnnotationRequest>();
            }
            else if (key == AnnotationKey.Taverna)
            {
                return this._container.Resolve<TavernaAnnotationRequest>();
            }
            else if (key == AnnotationKey.PubMedSearch)
            {
                return this._container.Resolve<PubMedAnnotationRequestStage>();
            }
            else
            {
                //cannot create request so return a 'default' stage that does nothing
                return new PassThroughAnnotationRequestStage();
            }
        }
    }
}
